home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: MegaDisc / MegaDisc 41 (1994-09)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).zip / MegaDisc 41 (1994-09)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).adf / ARexx_&_HBook / Quarl / QUARL.rexx < prev   
OS/2 REXX Batch file  |  1994-08-31  |  32KB  |  819 lines

  1.     /*                                                       */
  2.     /*        Quick  ARexx  Lookup -  An  ARexx  Utility     */
  3.     /*        By John Collett             September 1994     */
  4.     
  5.     /* Set your tab size to 4 for a comfortable read of this script */
  6.     
  7.     signal on syntax ; signal on error
  8.     if ~show('l','rexxarplib.library') then do
  9.      check = addlib('rexxsupport.library',0,-30,0) 
  10.      check = addlib('rexxarplib.library',0,-30,0) 
  11.      end  
  12.     address AREXX '"call CreateHost(HO, PORT)"'    
  13.     if ~show('Ports',HO) then address command 'WaitForPort HO' 
  14.     call SetReqColor(HO,SHADOWPEN,0) ; call SetReqColor(HO,BOXPEN,2)
  15.     w = 300 ; h = 178 
  16.     flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH'
  17.     idcmp = 'CLOSEWINDOW+GADGETUP'
  18.     call OpenWindow(HO,140,1,w,h,idcmp, flags,"Quick ARexx Lookup") 
  19.     call openport(PORT) ; call ActivateWindow(HO)
  20.     
  21.     /* Column 1 */
  22.     str = "Flow of Control;Functions and Args;Strings 1;Strings 2;" ||,
  23.     "Numbers;Operators;Bit manipulation;Data conversion;"||,
  24.     "Values and Variables;Console Input/Output;Files;Script Environment;"||,
  25.     "ARexx Environment;Messages and Ports;Operating System"
  26.     max = 20 ; left = 20 ; call BuildColumn(1)
  27.    
  28.     /* Fiddle with this program as much as you like, but if you alter the
  29.     entries beyond line 170, these increment settings will no longer be 
  30.     correct, and will have to be adjusted for the program to work. */
  31.     Inc.1 = 0 ; Inc.2 = 43 ; Inc.3 = 62 ; Inc.4 = 132 ; Inc.5 = 206 
  32.     Inc.6 = 249 ; Inc.7 = 300 ; Inc.8 = 337 ; Inc.9 = 365 ; Inc.10 = 391 
  33.     Inc.11 = 414 ; Inc.12 = 470 ; Inc.13 = 519 ; Inc.14 = 556 ; Inc.15 = 579    
  34.  
  35.     /* Find start points beyond current minimum */
  36.     last = sourceline() ; n = 170
  37.     do forever
  38.      n = n + 1 ; if sourceline(n) = '<1' then leave
  39.      end
  40.     do s = 1 to 15 ; start.s = n + Inc.s ;  end 
  41.     
  42.     /* Wait for user selection */
  43.     do forever   
  44.       call waitpkt(PORT) ; p = getpkt(PORT)   
  45.       if p ~== NULL() then do
  46.         i = getarg(p)
  47.         t = reply(p, 0)
  48.         parse var i class gadno x y .
  49.         select
  50.           when class = 'CLOSEWINDOW' then signal 'Finish'
  51.           when class = 'GADGETUP' then do
  52.            req = PostMsg() 
  53.            if gadno < 16 then call Gadget1() ; else call Gadget2()
  54.            end
  55.           otherwise
  56.           end    /* of 'select' */
  57.         end        /* of 'if ... then do' */
  58.       end      /* of 'do forever' */
  59.   
  60.     Finish:
  61.       req = PostMsg()
  62.       call CloseWindow(HO)
  63.       exit
  64.     syntax: say 'Syntax : ' errortext(rc) '. Line 'sigl ; signal 'Finish'
  65.     error: say "Error " rc sigl ; signal 'Finish'
  66.    
  67.     Gadget1:
  68.      if ngads > 15 then do
  69.        do g = 16 to ngads ; call RemoveGadget(HO,g) ; end
  70.        call APen(0) ; call RectFill(HO,186,12,w-6,h-4)
  71.        end
  72.      left = 200 ; call msg(2)
  73.      select
  74.       when gadno = 1 then do
  75.       str = "break;do;else;end;exit;if;interpret;iterate;leave;nop;",
  76.       || "otherwise;select;signal;then;when" ; max = 9
  77.       end
  78.      when gadno = 2 then do  
  79.       str = "arg;arg();call;procedure;return" ; max = 9
  80.       end
  81.      when gadno = 3 then do  
  82.       str = "compress;delstr;insert;overlay;strip;substr;translate;",
  83.        || "trim;upper;abbrev;compare;index;lastpos;pos;verify;center;"
  84.       max = 9
  85.       end
  86.      when gadno = 4 then do  
  87.       str = "left;reverse;right;space;delword;find;subword;word;",
  88.       || "wordindex;wordlength;words;copies;hash;length;parse;xrange"
  89.       max=10 ; end
  90.      when gadno = 5 then do  
  91.       str ="abs;digits;form;fuzz;max;min;numeric;random;randu;sign;trunc"
  92.       max = 7 ; end
  93.      when gadno = 6 then do  
  94.       str ="~;+ -;** *;/ % //;||;== ~==;= ~=;> >= ~<;< <= ~>;& |;^ &&"
  95.       max = 7 ; end
  96.      when gadno = 7 then do  
  97.       str ="bitand;bitchg;bitclr;bitcomp;bitor;bitset;bittst;bitxor"
  98.       max = 7 ; end
  99.      when gadno = 8 then do  
  100.       str ="b2c;c2b;c2d;c2x;d2c;d2x;x2c;x2d" ; max = 3 ; end
  101.      when gadno = 9 then do  
  102.       str ="datatype;drop;symbol;value" ; max = 8 ; end
  103.      when gadno = 10 then do  
  104.       str ="echo;lines;pull;push;queue;say" ; max = 5 ; end
  105.      when gadno = 11 then do  
  106.      str ="close;eof;open;readch;readln;seek;writech;writeln;",
  107.       || "delete;exists;makedir;rename;showdir;statef" ; max = 7 ; end
  108.      when gadno = 12 then do  
  109.       str ="date;errortext;options;sourceline;time;trace;trace()" 
  110.       max = 10 ; end
  111.      when gadno = 13 then do  
  112.       str ="addlib;address;address();freespace;getclip;getspace;remlib;",
  113.       || "setclip;shell;show" ; max = 9 ; end
  114.      when gadno = 14 then do  
  115.       str ="closeport;getarg;getpkt;openport;reply;typepkt;waitpkt"
  116.       max = 9 ; end
  117.      when gadno = 15 then do  
  118.       str ="allocmem;baddr;delay;export;forbid;freemem;import;",
  119.        || "next;null;offset;permit;pragma;showlist;storage" ; max = 8
  120.       end
  121.      otherwise
  122.      end
  123.      activeset = gadno ; call BuildColumn(16) ; call LoadList()
  124.      call APen(3) ; call RectFill(HO,186,gadno*10+4,192,gadno*10 +12)
  125.      call msg(0)
  126.      return
  127.  
  128.     msg: call APen(arg(1)) ; call Move(HO,80,172) ; call Text(HO,"Loading")
  129.       return
  130.  
  131.     LoadList:
  132.     /* Get starting lines for current set of column 2 gadgets */
  133.      start = start.activeset ; n_in_set = ngads - 15
  134.      start.activeset.1 = start ; n = 0
  135.      do s = 2 to n_in_set
  136.       do forever
  137.        n = n + 1 ; if sourceline(start+n) = '' then leave
  138.        end
  139.       start.activeset.s = start + n
  140.       end
  141.       return
  142.     
  143.     Gadget2:
  144.      rank = gadno-15 ; lef = 212+max*8
  145.      /*call APen(0) ; call RectFill(HO,lef,12,w-6,h-12) ; call APen(1)*/
  146.      line_num = start.activeset.rank ; j = 0 ; msg = ''
  147.      /* Get the lines for this commentary */
  148.      do forever
  149.       j = j + 1 ; thisl = line_num + j ; line = sourceline(thisl) 
  150.       if strip(line) = '' then leave
  151.       msg = msg || line
  152.       end   
  153.       longest = 0 ; n = 0 ; f = 1   
  154.       do forever
  155.        /* Dissect the message for '\'s, to know how deep the message box
  156.       will be, to help determine its position */
  157.       n = n + 1 ; s = index(msg,'\',f)
  158.       if s > 0 then longest = max(longest,s-f)
  159.       else do ; longest = max(longest,length(msg)-f) ; leave ; end
  160.       f = s + 1
  161.       end
  162.       if n < 4 then y = h+10 ; else y = 230 - n*10
  163.       longest = max(longest,24) ;  x = 270 - longest*4
  164.       req = PostMsg(x,y,msg)
  165.      return   
  166.      
  167.     BuildColumn:               /* of clickable gadgets */
  168.      do i = 1 until str = ''
  169.      parse var str a ';' str ; a = a || copies(' ',max-length(a))
  170.      call AddGadget(HO,left,4+10*i,arg(1)+i-1,a,'%l %d')
  171.      end
  172.      ngads = arg(1)+i-1 ; x = max*8 + 4 ; y = 3+10*(i+1)
  173.      call APen(2) ; call Move(HO,left,y)
  174.      call Draw(HO,left+x,y) ; call Draw(HO,left+x,14)
  175.      call APen(0) ; call Move(HO,left-2,y+1) ; call Draw(HO,left,y+1)
  176.      return
  177.  
  178.     APen: call SetAPen(HO,arg(1)) ; return
  179. /*
  180. <1
  181. BREAK\Exit from innermost DO-END block\or INTERPRET instruction
  182.  
  183. DO\Begin a block of instructions or a loop\DO FOREVER\DO [FOR] count\
  184. DO WHILE/UNTIL test\DO var=start [TO limit] [BY step]\
  185. DO [FOR] count WHILE/UNTIL test\
  186. DO var=start [TO limit] [BY step] FOR count\
  187. Do var=start [TO limit] [BY step] WHILE/UNTIL test\
  188. DO var=start [TO limit] [BY step] FOR count WHILE/UNTIL test
  189.  
  190. ELSE\Introduce code to be executed\when an IF test fails\ELSE [;] instruction
  191.  
  192. END [var]\Terminate a block of instructions\beginning with DO or SELECT
  193.  
  194. EXIT [expr]\Terminate a script
  195.  
  196. IF\Introduce code to be executed\if test expression is True\
  197. IF test [;]\ THEN [;] instruction\ [ELSE [;] instruction]
  198.  
  199. INTERPRET [expr]\Execute ARexx instructions\contained in a string
  200.  
  201. ITERATE [var]\Skip to the end of the\current iterative loop
  202.  
  203. LEAVE [var]\Break out of current iterative loop
  204.  
  205. NOP\Do nothing - a dummy instruction
  206.  
  207. OTHERWISE\Introduce default case\for SELECT control structure\
  208. OTHERWISE [;] [instruction(s)]
  209.  
  210. SELECT\Branch to first case whose\controlling condition is met\
  211. SELECT\  WHEN ...\  [OTHERWISE [;] [instructions]]\  END
  212.  
  213. SIGNAL\Trap for various kinds of errors as required,\
  214. or to transfer control to a label (like a GO TO!)\
  215.   SIGNAL ON type\  SIGNAL OFF type\  SIGNAL [VALUE] label-expression
  216.  
  217. THEN\Execute dependent instruction\if preceding expression was True\
  218. THEN [;] instruction
  219.  
  220. WHEN\In SELECT, introduce code to be\executed if test is True\
  221. WHEN test [;] THEN [;] instruction
  222.  
  223. <2
  224. ARG [template] [,template ...]\Shorthand form of PARSE UPPER ARG\
  225. Used to split input strings into substrings.
  226.  
  227. ARG()\Return information about function arguments;\
  228. how many there are, what each one is...\
  229.   numargs = ARG()\  argn = ARG(num)\  bool = ARG(num, mode)\
  230. Modes:   E - Exists   O - Omitted
  231.  
  232. CALL function arg, arg, arg\or CALL function(arg, arg, arg)\
  233. To invoke a function when what it DOES is its\
  234. purpose, and a returned RESULT is not required.
  235.  
  236. PROCEDURE [EXPOSE var [var ...]]\
  237. Protect variables within a function\call from name collisions,\
  238. but allow sharing (EXPOSE) of any\which need to be passed in or out.
  239.  
  240. RETURN [expr]\Return control (and\optionally a value) to caller
  241.  
  242. <3  
  243. COMPRESS\s = COMPRESS(str, [list])\
  244. Remove the characters in list (default=space) from str\
  245.   compress("writhing","rg") -> within
  246.  
  247. DELSTR\s = DELSTR(str, start, [len])\
  248. Delete len (default=rest of str) characters\
  249. from str, from start\  delstr("writhing",2,4) -> wing
  250.  
  251. INSERT\s = insert(istr,str,[start],[len],[pad])\
  252. Insert len characters of istr into str at start\
  253.   insert("inky","thing",2,3) -> thinking
  254.  
  255. OVERLAY\s = OVERLAY(new, old, [start], [len], [pad])\
  256. Overlay len characters of new on old, from start\
  257.   overlay("irrational","invitation",1,3) -> irritation
  258.  
  259. STRIP\s = STRIP(str, [mode], [list])\
  260. Strip leading and/or trailing characters in list from str\
  261. Modes:   B - Both (default)   L - Leading  T - Trailing\
  262.   strip("slaughters","b","s")  ->  laughter
  263.  
  264. SUBSTR\s = SUBSTR(str, start, [len],[pad])\
  265. Extract len (default=rest of str)\characters of str, from start\
  266.   substr("Jericho",3,4)  -> rich   
  267.  
  268. TRANSLATE\s = TRANSLATE(str)\s = TRANSLATE(str,[output],[input],[pad])\
  269. Translate str using input and output character tables\
  270.   translate("abracadabra",xrange("1","4"),xrange("a","d")\  -> 12r131412r1
  271.  
  272. TRIM\s = TRIM(str)\Remove trailing blanks from str\
  273.   str1 = "abcde     "                length(str1) is 10\
  274.   str2 = trim(str1)   ->  abcde      length(str2) is 5
  275.  
  276. UPPER var [var ...]\Convert contents of variables to upper case\
  277. s = UPPER(str)\Convert str to upper case\  upper("example")  -> EXAMPLE  
  278.  
  279. ABBREV\bool = ABBREV(str, abbr, [len])\Test if abbr is an abbreviation of str
  280. \with at least len characters\  abbrev("Program","Prog",4)   ->  1\
  281.   abbrev("Process","Prog",4)   ->  0\  abbrev("Process","Pro",4)    ->  0
  282.  
  283. COMPARE\n = COMPARE(str1, str2, [pad])\
  284. Determine position at which strings differ\
  285. (0 if identical)\  compare("different","difference")  -> 9
  286.  
  287. INDEX\n = INDEX(str,pat,[start])\Return position of pat in str, from 1 or\
  288. start (0 if not found)\  index("Where in the world","e",6)  -> 12\
  289.   index("Where in the world","w")    -> 14\
  290.   index("Where in the world","W",2)  -> 0\
  291. Same as 'pos' except for the order of the arguments.
  292.  
  293. LASTPOS\n = LASTPOS(pat,str,[start])\Return position of pat in str, searching\
  294. backwards from end or start\  lastpos("e","Where in the world")     -> 12\
  295.   lastpos("e","Where in the world",10)  -> 5 
  296.  
  297. POS\n = POS(pat,str,[start])\Return position of pat in str,\
  298. from 1 or start (0 if found)\  pos("e","Where in the world",6)  -> 12\
  299.   pos("w","Where in the world")    -> 14\
  300.   pos("W","Where in the world",2)  -> 0\See also 'index'
  301.  
  302. VERIFY\n = VERIFY(str,list,[match],[start])  Search str\from 1 
  303. or start for characters in list; return index or 0\
  304. Modes (match) : M - Return index of first list character of str\
  305.     Other/default - Return index of first non-list character\
  306.   verify("abracadabra","r","m",4)  -> 10\  verify("abridgement","abcde")    -> 3
  307.  
  308. CENTRE\s = CENTRE(str, width, [pad])\Center str in a field of given width\
  309.   centre("Middling",14)       ->  "   Middling   "\
  310.   center("Middling",16,"-")   ->  "----Middling----"
  311.  
  312. <4
  313. LEFT\s = LEFT(str,count,[pad])\Extract leftmost count characters of str,\
  314. pad on right if needed\  left("extraction",5)          -> extra\
  315.   left("Total ",12,".") $20.00  -> "Total ...... $20.00
  316.  
  317. REVERSE\s = REVERSE(str)\Reverse str\  reverse("drawer")   ->  reward
  318.  
  319. RIGHT\s = RIGHT(str,width,[pad])\
  320. Extract rightmost width characters of str,\pad on left if needed
  321.   right("extraction",6)  ->  action\  right("12345",6,"$")   ->  $12345
  322.  
  323. SPACE\s = SPACE(str, [len], [pad])\
  324. Set word-breaks in str to len spaces (or pad)\
  325.   space("Space it out",3)   ->    Space   it   out\
  326.   space("| | | |",4,"-")    ->    |----|----|----|
  327.  
  328. DELWORD\s = DELWORD(str, start, [len])\
  329. Delete len words from str, beginning at start word\
  330.   delword("Cut it out",2,1)  ->  Cut out
  331.  
  332. FIND\n = FIND(str, phrase)\Return position of word-string phrase in str\
  333.   find("Where in the world","in the") ->  2\
  334.   find("Where in the world","here")   ->  0
  335.  
  336. SUBWORD\s = SUBWORD(str, start, [count])\
  337. Extract count words (default=rest of str)\from str, from start word\
  338.   subword("Extract the third to fifth words",3,3)\ 
  339.           -> third to fifth
  340.  
  341. WORD\s = WORD(str,n)\Extract word n from str\
  342.   word("Extract the third word",3) -> third 
  343.  
  344. WORDINDEX\n = WORDINDEX(str,n)\Determine character position in str\
  345. of start of word n\  wordindex("Where in the world",4)  ->  14
  346.  
  347. WORDLENGTH\n = WORDLENGTH(str,n)\Determine length of word n in str\
  348.   wordlength("How long is the targetted word?",5)  ->  9
  349.  
  350. WORDS\n = WORDS(str)\Return number of words in str\
  351.   words("How many words are here?")  ->  5
  352.  
  353. COPIES\s = COPIES(str, n)\Concatenate n copies of str\
  354.   copies("-",10)        ->   ----------\  copies("<*>",4)       ->  <*><*><*><*>
  355.  
  356. HASH\n = HASH(str)\Calculate a hash value for str\
  357.   hash('A')   -> 65       hash('a')   -> 97\
  358.   hash('AB')  -> 131      hash('ab')  -> 195\
  359.   hash("What is the point?")          -> 122\
  360. I never use HASH, probably because I don't understand\
  361. how it might be of any use.  It is one way of getting\
  362. the ASCII value of a character, but ...
  363.  
  364. LENGTH\n = LENGTH(str)\Return length of str in characters\
  365.   length('antidisestablishmentarianism')   ->   28
  366.  
  367. PARSE\PARSE [UPPER] source [template] [,template]\
  368. Split input string(s) into substrings\
  369. (Could do with a gadget column of its own.)\
  370. Source name  Source string contents\
  371.   ARG        Arguments to present script or internal function\
  372.   EXTERNAL   Input via STDERR file\
  373.   NUMERIC    NUMERIC options: digits fuzz form\
  374.   PULL       Input via STDIN file\
  375.   SOURCE     type result called resolved ext host\
  376.              Info about how current script was called\
  377.   VALUE expr WITH    Result of expression\
  378.   VAR varname        Contents of varname\
  379.   VERSION    version cpu mpu video freq\
  380.              Info about ARexx version and machine setup
  381.  
  382. XRANGE\s = XRANGE([c1],[c2])\Build character string from c1 to c2\
  383. with consecutive ASCII values\    xrange("1","9")          ->  123456789\
  384.     length(xrange("a","z"))  ->  26
  385.  
  386. <5
  387. ABS\absval = ABS(num)\Return absolute value of numeric expression\
  388.   abs(2)  ->  2   abs(-1)  ->  1 
  389.     
  390. DIGITS\n = DIGITS()\Return current NUMERIC DIGITS setting\
  391.   Default :  digits()             ->  9\  Reset   :  numeric digits 3\
  392.   Check   :  digits()             ->  3\
  393.   Use     :  x = 2 * 1.12345      ->  2.25
  394.  
  395. FORM\f = FORM()\Return current NUMERIC FORM setting\
  396.   Default :  form()   ->  SCIENTIFIC\  Reset   :  numeric form engineering\
  397.   Check   :  form()   ->  ENGINEERING
  398.  
  399. FUZZ\f = FUZZ()\Return current NUMERIC FUZZ setting\
  400. Used in making numeric comparisons\  Default :  fuzz()  ->  0\
  401.   Reset   :  numeric fuzz 2\  Check   :  fuzz()  ->  2\
  402. Cannot exceed one less than current numeric digits setting.
  403.  
  404. MAX\n = MAX(n1, n2 [, n3 ...])\Find the largest of a set of numbers\
  405.   max(1.1,10.2,100.5,1000.8)   ->  1000.8
  406.  
  407. MIN\n = MIN(n1, n2 [, n3 ...])\Find the smallest of a set of numbers\
  408.   min(1.1,10.2,100.5,1000.8)   ->  1.1
  409.  
  410. NUMERIC\NUMERIC DIGITS num\Set numeric calculation and display options\
  411.   NUMERIC FUZZ num\  NUMERIC FORM SCIENTIFIC\  NUMERIC FORM ENGINEERING\
  412. See under DIGITS, FORM, and FUZZ
  413.  
  414. RANDOM\n = RANDOM([low],[high],[seed])\
  415. Return pseudo-random integer between\low and high inclusive\
  416.  random()       ->  Any number from 0 to 999\
  417.  random(12,24)  ->  Any number from 12 to 24\
  418.  Seconds from 'time' makes a good seed :\   random(,,time('s'))
  419.  
  420. RANDU\n = RANDU([seed])\Return pseudo-random number between 0 and 1\
  421. See also RANDOM
  422.  
  423. SIGN\n = SIGN(num)\Determine the sign of a number\
  424.  sign(-3)   ->  -1\ sign(0)    ->   0\ sign(3)    ->   1
  425.  
  426. TRUNC\n = TRUNC(number,[places])\Truncate number to places decimal places\
  427.   trunc(12.34567)    ->  12\  trunc(12.34567,2)  ->  12.34 (not rounded)
  428.  
  429. <6
  430. Logical NOT  ~\
  431.   if ~exists(filename) then say "Can't find file"\
  432. The set of operators is listed in order of descending priority.\
  433. Logical NOT is top of the list, only equalled in priority by\
  434. unary plus and unary minus.
  435.   
  436. Unary and binary + and -\  Unary, with just one operand :   balance = -100\
  437.   Unary + exists, but is rarely used.\
  438.   Binary :  2 + 3 = 5 ; 1.00099 - 0.00009 = 1.0009
  439.  
  440. Exponentiation  ** ( = 'raised to the power of')\  3 ** 3 = 27\
  441. Multiplication  *\  3 * 3 = 9
  442.  
  443. Division\  Division          /  : 7 / 2  = 2.333\
  444.   Integer division  %  : 7 % 3  = 2\  Remainder         // : 7 // 3 = 1\
  445. Some languages use the terms DIV and MOD\for the second and third of\
  446. these; e.g. 7 MOD 3 = 1
  447.  
  448. Concatenation  ||\Use || to join strings together\with no intervening space.\
  449. If you use a space you'll get a space.\  a = "Mega" ; b = "Disc" \
  450.   say a b a || b    ->   Mega Disc MegaDisc
  451.  
  452. Exact equality and exact inequality  ==  ~==\
  453. These are used less often than = and ~=,\but they can be useful.\
  454.   "Mega " ==  "Mega"   ->  0   (NOT exactly equal)\
  455.   "Mega " =   "Mega"   ->  1   (Roughly equal)\
  456.   "Mega " ~== "Mega"   ->  1   (Not exactly equal)
  457.  
  458. Equality and inequality  =  ~=\Rugged everyday workhorses, not fussy, for\
  459. example, about leading or trailing spaces\
  460. when they declare strings to be equal or not.\
  461.   "Disc" = "Disc "     ->  1\  "Disc" = "Disk"      ->  0
  462.  
  463. Greater than              >\Greater than or equal to  >=\
  464. Not less than             ~<\
  465. The second and third of the trio are of course equivalent.\
  466. Use whichever best expresses what you want to say.\
  467.   toffee_ready = (temperature >= boiling)
  468.  
  469. Less than                 <\Less than or equal to     <=    }  These two\
  470. Not more than             ~>    }  are synonymous\See also > >= ~<
  471.  
  472. AND and OR\Logical AND    & : if ready & willing then ...\
  473. Inclusive OR   | : if tired | cold | hungry then ...\
  474.   Any one of these is enough to prevent me working.\
  475.     
  476. Exclusive OR   ^ or && :\
  477.   see_you_there = ( who_is_going_to_be_there = (Jane ^ Mary) )\
  478.   If they're BOTH going, then I'm not.\&& is an alternative to ^.
  479.  
  480. <7
  481. BITAND\s = BITAND(str1, [str2], [pad])\
  482. Return bit-wise AND of two strings, padded to equal length\
  483.  c2b(bitand('11110000'b,'10001111'b))  ->  10000000\
  484.  c2b(bitand('11110000'b))              ->  00100000\
  485. I can't imagine any of the Bit functions being much use,\
  486. but somebody might be interested, and I include them for\
  487. the sake of attempted completeness.
  488.  
  489. BITCHG\s = BITCHG(str, n)\Invert bit n, counting from right, in str\
  490. 'Invert' means swap 0 and 1\
  491. With i = 1 to 5, bitchg('A',i) yields C, E, I, Q, a\
  492.  bitchg('dog',21)"          ->  Dog\ reverse(bitchg('dog',5))"  ->  God
  493.  
  494. BITCLR\s = BITCLR(str, n)\Clear bit n, counting from right, in str\
  495. 'Clear' means set to 0\  bitclr('d',5)  -> D\  bitclr('D',5)  -> D
  496.  
  497. BITCOMP\n = BITCOMP(str1, str2, [pad])\Return first bit,\
  498. counting from right,\at which str1 ~= str2 (-1 if equal)\
  499.   bitcomp('Dog','dog')"  -> 21\  bitcomp('Dog','dig')"  ->  9\
  500.   bitcomp('Dog','doe')"  ->  1
  501.  
  502. BITOR\s = BITOR(str1, [str2], [pad])\
  503. Return bit-wise OR of two strings,\padded to equal length\
  504.   bitor('ABCdef')     ->  abcdef\  bitor('Dog','doe')  ->  dog\
  505.   bitor('Dig','doe')" ->  dog
  506.  
  507. BITSET\s = BITSET(str, n)\Set bit n, counting from right in str\
  508. The opposite of BITCLR.\  bitset('d',5)  -> d\  bitset('D',5)  -> d
  509.  
  510. BITTST\bool = BITTST(str, n)\Test bit n, counting from right, in str\
  511.   bittst('A',6)  ->  1    bittst('A',5)  ->  0 
  512.     
  513. BITXOR\s = BITXOR(str1, [str2], [pad])\
  514. Return bit-wise exclusive-OR of two strings,\padded to equal length\
  515.   bitxor("ABCdef")  ->  abcDEF\  bitxor("A","1")   ->  p
  516.  
  517. <8
  518. B2C\s = B2C(binstr)\Return character equivalent of binary string\
  519.   b2c("01011001 01100101 01110011")  ->  Yes
  520.  
  521. C2B\b = C2B(str)\Return binary digit string\equivalent to character string\
  522.   c2b("Yes")'  ->  010110010110010101110011
  523.  
  524. C2D\n = C2D(str, [len])\
  525. Return integer number corresponding\to string (of len bytes)\
  526.   c2d("A")    -> 65\  c2d("AB",1) -> 66  (truncated to 'B')\
  527.   c2d("A"x)   -> 10\  c2d("FF"x)  -> 255\  c2d("Yes")' -> 5858675
  528.  
  529. C2X\h = C2X(str)\Return hexadecimal number\corresponding to string\
  530.   c2x("A") ->  41\   x2d(c2x("A"))  ->  65
  531.  
  532. D2C\s = D2C(num,[count])\Return string equivalent,\
  533. count bytes long, of num\  d2c(65)      ->  A\  d2c(5858675) -> Yes
  534.  
  535. D2X\h = D2X(num,[count])\Return hexadecimal string,\
  536. count bytes long, equivalent to num\  d2x(65)  ->  41\  d2x(16)  ->  10
  537.  
  538. X2C\s = X2C(hex)\Return character equivalent of hex string\
  539.   x2c(41 42 43 44 61 62 63 64)  ->  ABCDabcd
  540.  
  541. X2D\n = X2D(hex,[n])\Convert n rightmost digits (or all)\
  542. of hex string to decimal\  x2d(ff)   -> 255\  x2d(0f)   ->  15\
  543.   x2d(0f,1) ->  -1
  544.  
  545. <9
  546. DATATYPE  : type = DATATYPE(str)\  bool = DATATYPE(str,mode)\
  547. Test attributes of string (type = `NUM' or `CHAR')\
  548.   datatype(4)  ->  NUM    datatype("Yes")  ->  CHAR\
  549. If mode is specified, 1 or 0 is returned :\
  550. Modes:   A - Alphanumeric  B - Binary        L - Lower case\
  551.          M - Mixed case    N - Numeric       S - Symbol\
  552.          U - Upper case    W - Whole number  X - Hexadecimal\
  553.   datatype("YES",U) -> 1\  datatype("YES",L) -> 0\  datatype("Yes",M) -> 1
  554.   datatype(1.2,W)   -> 0\  datatype(12,W)    -> 1
  555.  
  556. DROP var [var ...]\Restore a variable to its uninitialized state\
  557.   say assigned  ; ASSIGNED\  assigned = 3  ; say assigned ; 3\
  558.   drop assigned ; say assigned ; ASSIGNED
  559.  
  560. SYMBOL\s = SYMBOL(str)\Determine if a string is a valid ARexx symbol\
  561. Returns LIT : a literal number or a valid but unused string\
  562.         VAR : a variable name to which a value has been attached\
  563.     or  BAD : neither of the above    
  564.  
  565. VALUE\val = VALUE(str)\Treating str as an ARexx symbol,\return its value\
  566. It can, for example, handle user choices concisely:\
  567.   A_String = 24 ; B_String = 39 ; C_String = 55 ....\
  568.   pull type ; say value(type || "_String")\
  569. If a user enters "A", the program will return "24"
  570.  
  571. <10
  572. ECHO expr\Send the expression result\to the standard output\A synonym of 'say'.
  573.  
  574. LINES\n = LINES([file])\Return number of lines queued\for interactive stream
  575. Works only with certain console handlers\such as Bill Hawes' ConMan, not\
  576. with standard Amigas as purchased.
  577.  
  578. PULL [template] [,template ...]\Shorthand form of PARSE UPPER PULL\
  579.   parse upper pull a   Input :  John\  parse pull b                  John\
  580.   pull c                        John\
  581.   say a b c            Output : JOHN John JOHN
  582.  
  583. PUSH expr\Pre-load the standard input\in `last-in, first-out' order\
  584. Needs ConMan or AmigaDOS 2.0 +\Run this as an ARexx program :\
  585.   push 'list s:' ; push 'list libs:'\The 'libs:' listing will appear first.
  586.  
  587. QUEUE expr\Pre-load the standard input\in `first-in, first-out' order\
  588. See the 'PUSH' entry.\Change 'push' to 'queue'\ and compare the order.
  589.  
  590. SAY [expr]\Send expression result to\standard output (usually console)\
  591.    rx 'say "If this program is run from CLI,\
  592.             this will appear in the CLI window."'
  593.  
  594. <11
  595. CLOSE\bool = CLOSE(file)\Close the named file.
  596.  
  597. EOF\bool = EOF(file)\Return 1 if end of file\has been detected; else 0\
  598.  Examples :  do until eof(myfile) ...\             if eof(myfile) then ...\
  599.              do while ~(eof(myfile)) ...
  600.  
  601. OPEN\bool = OPEN(file, name, [mode])\
  602. Open a file called name in given mode\Modes:  R - Read (default)\
  603.         W - Write (create)\        A - Append\
  604. op = open(f,'MyFile',w)  ->  New file opened for writing\
  605. op = open(f,'MyFile',r)  ->  Existing file opened for reading
  606.  
  607. READCH\s = READCH(file, [count])\Read count characters from file
  608.  
  609. READLN\s = READLN(file)\Read a line from file
  610.  
  611. SEEK\n = SEEK(file,offset,[mode])\
  612. Move file position to offset according to mode\
  613. Modes: C - Current (default)  B - Beginning  E - End\  n = seek(f)\
  614.     Will return current pointer position.\  n = seek(f,100)\
  615.     Pointer will move 100 bytes forward.\  n = seek(f,100,b)\
  616.     Pointer will move to 100 bytes from beginning of file.
  617.  
  618. WRITECH\n = WRITECH(file, str)\Write str to file, return count written\
  619.   n = writech(f,'entry')\  n  ->  5
  620.  
  621. WRITELN\n = WRITELN(file, str)\
  622. Write str plus linefeed to file,\return count written\
  623.   n = writeln(f,'entry')\  n -> 6   (5 chars + LF)
  624.  
  625. DELETE\bool = DELETE(name)\Delete a file or directory
  626.  
  627. EXISTS\bool = EXISTS(name)\Return True if given file or directory exists
  628.  
  629. MAKEDIR\bool = MAKEDIR(dirname)\Create a directory of the given name
  630.  
  631. RENAME\bool = RENAME(oldname, newname)\Rename a file or directory
  632.  
  633. SHOWDIR\filelist = SHOWDIR(dir, [mode], [pad])\
  634. List the file and/or directory names in a directory\
  635. Modes: A - All (default)  F - Files only  D - Directories only\
  636.     fl = showdir(c,f,'0a'x)\
  637. Will list all files in 'c' directory in a single column,\
  638. the linefeed character ('0a'x) being used as the pad.
  639.  
  640. STATEF\filestring = STATEF(pathname)\
  641. Obtain information about a file or directory\
  642. Format: type size blk bits day min tick com\    type -> FILE or DIR\
  643.     size -> in bytes\    blk  -> in blocks\    bits -> protection settings\
  644.     day  -> creation date in days since 1/1/1988\
  645.     min  -> creation time in minutes since midnight\
  646.     tick -> creation time in ticks within the minute\
  647.     com  -> filenote, if any\This file (as I'm writing it) has just returned\
  648. FILE 22041 44 ----RWED 6085 526 2429 
  649.  
  650. <12
  651. DATE\d = DATE([outmode],[indate],[inmode])\
  652. Find today's date, or info about a specified date\
  653. Modes:\  B - Base (days since 01/01/0000)\  C - Century (days this century)\
  654.   D - Days (days since start of year, counting today)\
  655.   E - European (dd/mm/yy - e.g. 19/11/76)\
  656.   I - Internal (days since 01/01/1978)\
  657.   J - Julian (yyddd - 2-digit year, 3-digit days this year)\
  658.   M - Month name in English mixed case (e.g. `November')\
  659.   N - Normal, the default (dd mmm yyyy, e.g. 01 Jun 1986)\
  660.   O - Ordered (yy/mm/dd, e.g. 84/05/24)\
  661.   S - Standard (yyyymmdd, e.g. 19921005)\  U - USA (mm/dd/yy, 12/21/88)\
  662.   W - Weekday name in English mixed case (e.g. `Thursday')
  663.  
  664. ERRORTEXT : text = ERRORTEXT(n)\
  665. Return a description of syntax error number n\
  666.   errortext(1)  ->  Program not found\  errortext(2)  ->  Execution halted\
  667.   errortext(3)  ->  Insufficient memory\Numbers go up to 48, with a few gaps.
  668.  
  669. OPTIONS  Script options\  OPTIONS [NO] RESULTS  Default is 'off'.\
  670.   Set it to 'on' if feedback required from another program.\
  671.   OPTIONS [NO] CACHE\ 
  672.   Default is 'on', for 'an internal statement-caching scheme'.\
  673.   OPTIONS PROMPT [expr]\  Set prompt strings to appear in PULL operations.\
  674.   OPTIONS FAILAT expr\ To specify a failure level for error reporting.
  675.  
  676. SOURCELINE: n = SOURCELINE()\            s = SOURCELINE(num)\
  677. Read count of source lines, or\line num from current script.\
  678. Much used in this program,\ to find each of these notes.
  679.  
  680. TIME\t = TIME([mode])\Find current or elapsed time\Modes:\
  681.   C - Civil (h:mmAM or h:mmPM, e.g. 3:07AM)\
  682.   E - Elapsed (s.cc, seconds and hundredths, in interval)\
  683.   H - Completed hours since midnight (e.g. 4)\
  684.   M - Completed minutes since midnight (e.g. 243)\
  685.   N - Normal, the default (hh:mm:ss, e.g. 17:04:41)\
  686.   R - Same as elapsed, but resets timer to 0.00\
  687.   S - Completed seconds since midnight (e.g. 17353)
  688.  
  689. TRACE mode\  TRACE [VALUE] expr\  TRACE num\Set tracing mode\
  690. Modes:   A - All clauses B - Background     C - Commands\
  691.          E - Errors  I - Intermediates  L - Labels\
  692.          N - Normal  O - Off            R - Results\         S - Scan\
  693. Special features:\ ? - Interactive   +num - skip interactive pauses\
  694.  ! - Command inhibition  -num - trace suppression count
  695.  
  696. TRACE()\t = TRACE([mode])\
  697. Get/set tracing mode (see modes under TRACE instruction)
  698.     
  699. <13
  700. ADDLIB(name, pri, [offset, version])\
  701. Add function library/host name to library list
  702.  
  703. ADDRESS\ ADDRESS name\ ADDRESS VALUE name-expression\
  704.  ADDRESS name command-expression\Modify host address; send command to a host\
  705. Note format for sending an AmigaDOS command :\
  706. Without quotes, and within an ARexx program,\
  707.   'address command ' any_AmigaDOS_command\will carry out any_AmigaDOS_command
  708.  
  709. ADDRESS()\host = ADDRESS()\Return host address string
  710.  
  711. FREESPACE : n = FREESPACE()\ n = FREESPACE(addr, size)\
  712. Return size bytes of memory at addr\to ARexx's internal memory pool
  713.  
  714. GETCLIP\s = GETCLIP(clip)\Return value string associated with clip name\
  715. See also SETCLIP
  716.  
  717. GETSPACE  : addr = GETSPACE(size)\
  718. Allocate size bytes of memory in\ARexx internal memory pool\
  719. See also FREESPACE.\ I have never used either of them.
  720.  
  721. REMLIB\bool = REMLIB(name)\Remove an entry from the Library List,\
  722. e.g. if memory is in short supply\and a library is no longer needed.
  723.  
  724. SETCLIP\bool = SETCLIP(name, [value])\Set string value for clip name\
  725. (remove name if value omitted).\A good way to store strings (called 'clips')\
  726. which need to be shared by programs or passed\between programs.
  727.  
  728. SHELL\ SHELL name\ SHELL VALUE name-expression\
  729.  SHELL name command-expression\Modify host address; send command to a host\
  730. See also the ADDRESS instruction,\for which SHELL is an exact synonym.
  731.  
  732. SHOW\ s = SHOW(mode,,[pad])  Returns a list of names.\
  733.  bool = SHOW(mode,name)  Returns 1 or 0.\Modes:\ C - Clips\ F - Files\
  734.  I - Internal ports\ L - Function Libraries\ P - Public ports
  735.  
  736. <14
  737. CLOSEPORT : bool = CLOSEPORT(portname)\
  738. Close a message port opened with OPENPORT
  739.  
  740. GETARG\arg = GETARG(packet, [whicharg])\
  741. Obtain an argument string from a message packet
  742.  
  743. GETPKT\pkt = GETPKT(portname)\Pick up a message packet from a message port
  744.  
  745. OPENPORT\bool = OPENPORT(portname)\
  746. Open a public message port with the given name\
  747. See references to 'HO' within this program.
  748.  
  749. REPLY\1 = REPLY(pkt, [result], [result2])\
  750. Return a message packet to its sender,\default results = 0, 0
  751.  
  752. TYPEPKT\cmd = TYPEPKT(pkt)\  count = TYPEPKT(pkt,'a')\
  753.   bool  = TYPEPKT(pkt,mode)\Extract information from a message packet\
  754. Modes: F - Function   C - Command
  755.  
  756. WAITPKT\bool = WAITPKT(portname)\
  757. Wait for a message packet to arrive at a port
  758.  
  759. <15
  760. ALLOCMEM  : mem = ALLOCMEM(size, [type])\
  761. Allocate size bytes of system memory, with\
  762. type attributes. You will rarely need to use this.
  763.  
  764. BADDR\addr = BADDR(bptr)\Convert BPTR to address\
  765. 'Rather esoteric'.\  Do you REALLY want to know?
  766.  
  767. DELAY\0 = DELAY(n)\Pause for n 50ths of a second
  768.  
  769. EXPORT\count = EXPORT(addr,[str],[len],[pad])\
  770. Copy len bytes of str to memory at addr.\
  771. 'In practice ... rarely needed.... ARexx is\
  772. unable to protect you from yourself when using\
  773. this function.'(Zamara & Sullivan p.301)
  774.  
  775. FORBID\count = FORBID()\Turn off multitasking
  776.  
  777. FREEMEM\1 = FREEMEM(addr, size)\Free size bytes of memory at addr\
  778. allocated by ALLOCMEM
  779.  
  780. IMPORT\s = IMPORT(addr,[len])\Return contents of len bytes\
  781. (or 0-terminated) memory at addr\But see also EXPORT.
  782.  
  783. NEXT\value = NEXT(addr,[offset])\
  784. Return the 4-byte value stored at addr + offset\
  785. Handle with care.
  786.  
  787. NULL\'00000000'x = NULL()\
  788. Return a 4-byte string corresponding\to a null address\
  789.  
  790. OFFSET\addr = OFFSET(addr,amount)\Return the address addr + amount, useful,\
  791. for example, when locating fields within structures.
  792.  
  793. PERMIT\count = PERMIT()\Re-enable multitasking after FORBID
  794.  
  795. PRAGMA :\A collection of system-specific facilities\
  796. Current directory    oldcd = PRAGMA('d', [newcd])\
  797. Task priority       oldpri = PRAGMA('p', newpri)\
  798. Stack size         oldsize = PRAGMA('s', size)\
  799. DOS requesters           1 = PRAGMA('w', [mode])\
  800.                Modes : 'n' = on, 'w' or none = off\
  801. Task ID (address)       id = PRAGMA('i')\
  802. Console handler       bool = PRAGMA('*', [file])      
  803.  
  804. SHOWLIST  : list = SHOWLIST(mode,,[pad])\
  805.  bool = SHOWLIST(mode, name)\ addr = SHOWLIST(mode, name,, 'a')\
  806. Returns an astonishing amount of information, most of\
  807. which you will never need, about a shared system list\Modes:\
  808.  A - Assigns      D - Devices    H - Handlers\
  809.  I - Interrupts   L - Libraries  M - Memory\
  810.  P - Ports        R - Resources  S - Semaphore\
  811.  T - Ready tasks  V - Volumes    W - Waiting tasks\
  812. Note how the 2nd and 3rd arguments are never used together.
  813.  
  814. STORAGE\n = STORAGE()\ s = STORAGE(addr,[str],[len],[pad])\
  815. Copy len bytes of str to memory at addr.\ 
  816. Similar to EXPORT, but when used with no argument, returns\
  817. the amount of free memory in the system.
  818.   
  819. */